/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package architecture.impl;

import architecture.Architecture;
import architecture.ArchitecturePackage;
import architecture.Feature;
import architecture.Module;
import architecture.Responsability;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Architecture</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link architecture.impl.ArchitectureImpl#getHasFeatures <em>Has Features</em>}</li>
 *   <li>{@link architecture.impl.ArchitectureImpl#getName <em>Name</em>}</li>
 *   <li>{@link architecture.impl.ArchitectureImpl#getHasModules <em>Has Modules</em>}</li>
 *   <li>{@link architecture.impl.ArchitectureImpl#getHasResponsabilities <em>Has Responsabilities</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArchitectureImpl extends EObjectImpl implements Architecture {
	/**
	 * The cached value of the '{@link #getHasFeatures() <em>Has Features</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasFeatures()
	 * @generated
	 * @ordered
	 */
	protected EList<Feature> hasFeatures;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getHasModules() <em>Has Modules</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasModules()
	 * @generated
	 * @ordered
	 */
	protected EList<Module> hasModules;

	/**
	 * The cached value of the '{@link #getHasResponsabilities() <em>Has Responsabilities</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasResponsabilities()
	 * @generated
	 * @ordered
	 */
	protected EList<Responsability> hasResponsabilities;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArchitectureImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ArchitecturePackage.Literals.ARCHITECTURE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Feature> getHasFeatures() {
		if (hasFeatures == null) {
			hasFeatures = new EObjectContainmentEList<Feature>(Feature.class, this, ArchitecturePackage.ARCHITECTURE__HAS_FEATURES);
		}
		return hasFeatures;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ArchitecturePackage.ARCHITECTURE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Module> getHasModules() {
		if (hasModules == null) {
			hasModules = new EObjectContainmentEList<Module>(Module.class, this, ArchitecturePackage.ARCHITECTURE__HAS_MODULES);
		}
		return hasModules;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Responsability> getHasResponsabilities() {
		if (hasResponsabilities == null) {
			hasResponsabilities = new EObjectContainmentEList<Responsability>(Responsability.class, this, ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES);
		}
		return hasResponsabilities;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ArchitecturePackage.ARCHITECTURE__HAS_FEATURES:
				return ((InternalEList<?>)getHasFeatures()).basicRemove(otherEnd, msgs);
			case ArchitecturePackage.ARCHITECTURE__HAS_MODULES:
				return ((InternalEList<?>)getHasModules()).basicRemove(otherEnd, msgs);
			case ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES:
				return ((InternalEList<?>)getHasResponsabilities()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ArchitecturePackage.ARCHITECTURE__HAS_FEATURES:
				return getHasFeatures();
			case ArchitecturePackage.ARCHITECTURE__NAME:
				return getName();
			case ArchitecturePackage.ARCHITECTURE__HAS_MODULES:
				return getHasModules();
			case ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES:
				return getHasResponsabilities();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ArchitecturePackage.ARCHITECTURE__HAS_FEATURES:
				getHasFeatures().clear();
				getHasFeatures().addAll((Collection<? extends Feature>)newValue);
				return;
			case ArchitecturePackage.ARCHITECTURE__NAME:
				setName((String)newValue);
				return;
			case ArchitecturePackage.ARCHITECTURE__HAS_MODULES:
				getHasModules().clear();
				getHasModules().addAll((Collection<? extends Module>)newValue);
				return;
			case ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES:
				getHasResponsabilities().clear();
				getHasResponsabilities().addAll((Collection<? extends Responsability>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ArchitecturePackage.ARCHITECTURE__HAS_FEATURES:
				getHasFeatures().clear();
				return;
			case ArchitecturePackage.ARCHITECTURE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ArchitecturePackage.ARCHITECTURE__HAS_MODULES:
				getHasModules().clear();
				return;
			case ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES:
				getHasResponsabilities().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ArchitecturePackage.ARCHITECTURE__HAS_FEATURES:
				return hasFeatures != null && !hasFeatures.isEmpty();
			case ArchitecturePackage.ARCHITECTURE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ArchitecturePackage.ARCHITECTURE__HAS_MODULES:
				return hasModules != null && !hasModules.isEmpty();
			case ArchitecturePackage.ARCHITECTURE__HAS_RESPONSABILITIES:
				return hasResponsabilities != null && !hasResponsabilities.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //ArchitectureImpl
